﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CSharpAlgorithm
{
    class ABDictionary2
    {
        public ABDictionary2()
        {
            int testCase = Int32.Parse(TestConsole.ReadLine());
            while (testCase-- > 0)
            {
                string[] input = TestConsole.ReadLine().Trim().Split(' ');
                int a = Int32.Parse(input[0]);
                int b = Int32.Parse(input[1]);
                int k = Int32.Parse(input[2]);
                int[,] board = new int[a + 1, b + 1];

                for (int j = 1; j <= b; j++)
                { board[0, j] = 1; }

                for (int i = 1; i <= a; i++)
                {
                    for (int j = 1; j <= b; j++)
                    {
                        board[i, j] = board[i - 1, j] + board[i, j - 1];
                    }
                }

                int startPoint = 0;
                for (int i = 0; i <= a; i++)
                {
                    if (k > board[i, b])
                    {
                        k = k - board[i, b];
                    }
                    else
                    {
                        startPoint = i;
                        break;
                    }
                }
                if(startPoint == 0)
                {
                }
                else
                {
                    int newB = b - 1;
                    int value = 1;
                    Queue<int> resultQue = new Queue<int>();
                    for (int i = startPoint - 1; i >= 0; i--)
                    {
                        for (int j = newB; j >= 0; j--)
                        {
                            if (k > board[i, j])
                            {
                                k = k - board[i, j];
                                value++;
                            }
                            else
                            {
                                resultQue.Enqueue(value);
                                newB = j;
                                break;
                            }
                        }
                        value = 0;
                    }
                    Console.WriteLine();
                }

        

            }
        }
    }
}
